#include "XSystem/XCore.h"

// Constuct the button with the pre-defined data.
XPushButton::XPushButton(XResourcesManager *data, int width, int height, int positionX, int positionY) : XWidget(data, width, height, positionX, positionY)
{
	x_type = XG_TYP_PUSHBUTTON;

	x_backgroundShape = sf::Shape::Rectangle(x_positionX, x_positionY, (x_positionX + x_width), (x_positionY + x_height), sf::Color(64, 64, 64));
}

// Draws the button, depending of the state.
void XPushButton::Draw()
{
	x_app->Draw(x_backgroundShape);
}

// Check the state of the button.
void XPushButton::CheckState(const sf::Input &input)
{
	XWidget::CheckState(input);

	switch (x_state)
	{
		case XG_ST_MOUSE_ENTER:
			x_backgroundShape.SetColor(sf::Color(128, 128, 128));
			break;

		case XG_ST_MOUSE_EXIT:
			x_backgroundShape.SetColor(sf::Color(64, 64, 64));
			break;

		case XG_ST_LBUTTON_DOWN:
			x_backgroundShape.SetColor(sf::Color(16, 16, 16));
			break;

		case XG_ST_LBUTTON_RELEASED:
			x_backgroundShape.SetColor(sf::Color(128, 128, 128));
			break;
	}
}
